// pages/guide/guide.js
const util = require('../../utils/util.js')
const auth = require('../../utils/auth.js')

Page({
  /**
   * 页面的初始数据
   */
  data: {
    loadingData:false,
    sourse:'',
    id:'',
    content:'',
    brief:'',
    loading:false,
    showPic:true,
    mark:'http://p.qpic.cn/automall_pic/0/20180201152050_67673/0',
    mark1:'http://p.qpic.cn/automall_pic/0/20180226171052_37099/0'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      var id = options.id;
      var that=this;
      that.setData({
        id:id
      })
      util.ajax({
      url: 'act/actapi/detail',
      data: {
       id:that.data.id
      },
      header: {
          'content-type': 'application/json' // 默认值
      },
      success: function(res) {
        if(res && res.data){
          var sourse = res.data;
          var brief = res.data.brief;
          var content = res.data.content;
          var tempContent = new Array();
          for(var i=0;i<content.length;i++){
            tempContent[i] = new Array();
            tempContent[i].push(content[i].content.split("<&p&>"));
            content[i].content = tempContent[i];
          }
          if (that.data.id == 44) {
            that.setData({
              showPic:false
            })
          }
          that.setData({
              sourse:sourse,
              content:content,
              brief:brief,
              loading:true
           });
        } 
        that.setData({
            loadingData:true
        })
      }
    })
  },
 previewImage1: function(){
   console.log('点击图片');
   wx.previewImage({  
         urls: this.data.mark1.split(',')
      }) 
 },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})